package com.blueocean_health.care.management.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blueocean_health.care.management.em.HttpRequestMethodType;

/**
 * 只允许HttpRequestMethodType中的请求类型
 * @author meisanfeng
 *
 */
@WebFilter(filterName="httpRequestMethodFilter",urlPatterns="/*") 
public class Filter02_HttpRequestMethodFilter extends BasicFilter {
	
	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest) request;
		HttpServletResponse resp = (HttpServletResponse)response;
		try {
			HttpRequestMethodType type = HttpRequestMethodType.valueOf(req.getMethod());
			if(type != null){
				chain.doFilter(req, resp);
			}
		} catch (Exception e) {}
	}
}
